Fix for side-effects seeping into data query#419
Merged
teunbrand merged 10 commits intoposit-dev:mainfrom May 4, 2026
Merged
Conversation
transform_global_sql concatenated side-effect SQL (CREATE, INSERT, …) with the VISUALISE FROM injection, then the caller wrapped the whole thing in another CREATE TABLE AS, producing invalid SQL like: CREATE TABLE __ggsql_global__ AS CREATE TEMP TABLE data … Split the return into side-effect statements (executed directly) and the queryable part (wrapped as the global temp table). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…om/teunbrand/ggsql into fix_create_temp_table_global_query
Collaborator
|
I think this is old unneeded bagage that you are removing so no need for concern (and Claude agrees). A few comments but otherwise good
|
thomasp85
approved these changes
May 4, 2026
The tree-sitter lexer was misclassifying INSERT, UPDATE, and DELETE keywords as bare_identifier tokens, causing them to fall through to other_sql_statement instead of their specific statement rules. This happened because keyword prefixes (e.g. IN for INSERT) derailed the lexer's specific keyword path. Fix: wrap the three leading keywords in token(prec(1, ...)) so they get dedicated high-priority lexer tokens, and downgrade other_sql_statement's catch-all regex from token() to a bare regex. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
transform_global_sql returned empty side-effects when a SELECT was present, so CREATE/INSERT preambles were skipped. Hoist side-effect extraction so it runs regardless of the query type. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
It is good that you asked, because it exposed a bug in the grammar, where INSERT/DELETE/UPDATE etc weren't parsed as their
Addressed in b6805de
Renamed it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to fix #415.
The
transform_global_sql()was wrapping the user-provided query like so:Whereas now
CREATE TEMP TABLE data(x, y) AS (VALUE...is executed seperately as a side-effectCREATE TABLE "__ggsql_global_..." AS SELECT * FROM databecomes the global data queryI'm mainly concerned about Chesterton's fence: I don't really know why
CREATEstatements were transformed in the first place. So that'd be a good item to review.